package com.hxd.tabactivityfragment.ui.activity

import android.os.Handler
import com.hxd.tabactivityfragment.R
import com.hxd.tabactivityfragment.common.MyActivity
import com.hxd.tabactivityfragment.bean.UserBean
import com.hxd.tabactivityfragment.mvp.presenter.RegisterPresenter
import com.hxd.tabactivityfragment.mvp.view.IRegisterView
import com.hxd.tabactivityfragment.util.GsonToBean
import com.hxd.tabactivityfragment.util.L
import com.hxd.tabactivityfragment.util.URLProviderUtils
import com.kymjs.rxvolley.RxVolley
import com.kymjs.rxvolley.client.HttpCallback
import com.kymjs.rxvolley.client.HttpParams
import kotlinx.android.synthetic.main.activity_register.*

/**
 *  项目名：    FoodOrigins
 *  包名：      com.hxd.tabactivityfragment.ui.activity
 *  文件名:     RegisterActivity
 *  创建者:     HXD
 *  创建时间:   2019/3/21 17:03
 *  描述:       注册界面
 */

class RegisterActivity:MyActivity(),IRegisterView {

    private val mRegisterPresenter by lazy { RegisterPresenter() }

    override fun getLayoutId(): Int {
        return R.layout.activity_register
    }

    override fun getTitleBarId(): Int {
        return R.id.tb_title_register
    }

    override fun setLoadingText(): String? {
        return "正在注册中......"
    }

    override fun initListener() {
        mRegisterPresenter.bindView(this)
        btn_register.setOnClickListener {
            rxDialogShapeLoading!!.show()
            Handler().postDelayed({
                rxDialogShapeLoading!!.dismiss()
                mRegisterPresenter.register()
            },2000)
        }
    }

    override fun getName(): String {
        return et_name_register.text.toString()
    }

    override fun getAccount(): String {
        return et_account_register.text.toString()
    }

    override fun getPassword(): String {
        return et_password_register.text.toString()
    }

    override fun getconfirmPassword(): String {
        return et_confirmPsw_register.text.toString()
    }

    override fun registerSuccess(user: UserBean) {
        startActivityAndFinish<LoginActivity>()
        myToast("注册成功")
    }

    override fun showNetworkError() {

    }

    override fun getDataFail(msg: String) {
        myToast(msg)
    }

    override fun getPermissionSuccess() {

    }

    override fun getPermissionFail() {

    }

}